<template>

  <div style="margin: 30px 20px">
    <h2 style="text-align:center">投标书</h2>
    <div style="margin-bottom: 40px;">

          <el-input
              v-model="title"
              size="large"
              placeholder="请输入标题"
          />

    </div>

    <div id="editor" style="padding-top: 20px">
    </div>
    <div style="text-align: center;margin-top: 20px">
      <el-button type="primary" size="large" @click="send">发送</el-button>
    </div>
  </div>

</template>

<script>
import WangEditor from 'wangeditor'
import {ElMessage} from "element-plus";
import axios from 'axios'

export default {
  data() {
    return {
      editor: null,
      value: '',
      content: '',
      title: '',
      inviteId: ''
    }
  }, mounted() {
    const editor = new WangEditor('#editor')
    editor.create()
    this.editor = editor

  },
  methods: {
    send() {
      if (this.title === '') {
        ElMessage.error("请输入标题");
        return;
      }
      let content = this.editor.txt.html()
      if (content === '') {
        ElMessage.error("请输入内容");
        return;
      }
      axios.get("/project/bidd/add", {
        params: {
          title: this.title,
          info: content,
          inviteId: this.inviteId
        }
      }).then(resp => {
        if (resp.data.success) {
          ElMessage.success("发表成功")
          this.editor.txt.clear();
          this.title = '';
          this.value = ''
          this.$router.push('/seeBidd')
        }
      })
    }
  }, created() {
    this.inviteId = this.$route.query.id
  }
}
</script>

<style scoped>
</style>